package com.origin.netlibrary.interceptor

import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

/**
 * 设置动态请求时间
 */
class DynamicTimeoutInterceptor(private var dynamicTimeout: DynamicTimeout? = null) : Interceptor {

    interface DynamicTimeout {


        fun setUrlTimeout(url: String, chain: Interceptor.Chain, request: Request): Response


    }


    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val questUrl = request.url().toString()
        dynamicTimeout?.setUrlTimeout(questUrl, chain, request)
        return chain.proceed(request)
    }
}